package main

import (
	"fmt"
)

func main() {
	//fmt.Println(avgFloat(1,2,3,4,5,6,7,8,9))
	//setOrder(2,1)
	changeOrder(
		[]int{
			2, 5, 1, 3, 36, 7, 23, 4,
		})

}

func avgFloat(args ...float64) float64 {
	resule := 0.0
	for i := 0; i < len(args); i++ {
		resule += args[i]
	}
	return resule / float64(len(args))
}

func setOrder(args ...float64) {
	if len(args) > 2 || len(args) < 0 {
		return
	} else {
		if args[0] > args[1] {
			temp := args[0]
			args[0] = args[1]
			args[1] = temp
		}
	}
	fmt.Println(args)
}

var (
	index    = 0
	stackLen = 10
	stack    = make([]int, stackLen)
)

func push(val int) {
	if index >= 10 {
		fmt.Println("当前栈已满了")
		return
	}
	stack[index] = val
	index++
}

func pop() {
	if index <= 0 {
		fmt.Println("当前栈已经空了")
	}
	index--
}

func bobOrder(args []int) {
	var temp int
	for i := 0; i < len(args); i++ {
		for j := 0; j < len(args); j++ {
			if args[i] < args[j] {
				temp = args[i]
				args[i] = args[j]
				args[j] = temp
			}
		}
	}
	fmt.Println(args)
}

func changeOrder(args []int) {
	var val int
	var index int
	for i := 0; i < len(args); i++ {
		index = i
		val = args[i]
		for j := i; j < len(args); j++ {
			if args[i] < args[j] {
				index = j
				val = args[j]
			}
		}
		if index != i {
			args[index] = val
		}
	}
	fmt.Println(args)
}

func plusTwo() func(int) bool {
	return func(x int) bool {
		return x > 0
	}
}
